#include "rclcpp/rclcpp.hpp"

class MyNode : public rclcpp::Node
{
public:
    MyNode() : Node("my_node")
    {
        // 声明参数并设置默认值
        this->declare_parameter<int>("example_param", 0);

        // 获取参数
        int param_value = this->get_parameter("example_param").as_int();
        RCLCPP_INFO(this->get_logger(), "Initial parameter value: %d", param_value);

        // 修改参数值
        this->set_parameter(rclcpp::Parameter("example_param", param_value + 10));

        // 获取修改后的参数值
        int new_value = this->get_parameter("example_param").as_int();
        RCLCPP_INFO(this->get_logger(), "Updated parameter value: %d", new_value);

    }
};

int main(int argc, char **argv)
{
    rclcpp::init(argc, argv);
    auto node = std::make_shared<MyNode>();
    rclcpp::spin(node);
    rclcpp::shutdown();
    return 0;
}
